<template>
  <basic-dialog
    :width="'60%'"
    :visible="visible"
    :title="'异常记录'"
    :handle-close="onCancel"
    :handle-open="getTableData"
    :show-footer="false"
  >
    <BasicList
      :show-select-col="false"
      :loading="tableInfo.loading"
      :total="total"
      :data-source="tableInfo.list"
      :columns="columns"
      :tableHeight="493"
      :pagination="pagination"
      @pageChange="handlePageChange"
      @pageSizeSelect="handlePageSizeChange"
    />
  </basic-dialog>
</template>

<script>
import BasicDialog from '@sourcing/components/BasicDialog';
import BasicList from '@sourcing/components/BasicList';
import BasicPage from '@/mixins/sourcing/basicPage';
import { getAbnormalRecordService } from '@/api/sourcing/demandInquery';

export default {
  mixins: [BasicPage],
  components: {
    BasicDialog,
    BasicList
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    setdiolagdata: {
      type: Object,
      required: true,
    },
  },
  data () {
    return {
      quoteForm: {},
      formValidate: {},
      pagenation: {
        pageSize: 10,
        pageNum: 1,
      },
      columns: [
        {
          prop: 'billNo',
          label: '单据号',
        },
        {
          prop: 'skuName',
          label: '商品名称',
        },
        {
          prop: 'expInquiryReason',
          label: '异常原因',
        },
        {
          prop: 'expInquiryRemark',
          label: '异常说明',
        },
        {
          prop: 'creatorName',
          label: '提交人',
        },
        {
          prop: 'creationDate',
          label: '提交时间',
        }
      ]
    };
  },
  methods: {
    async getTableData () {
      const { tabtype, selectionChangeval } = this.setdiolagdata;
      const params = {
        entryIds: selectionChangeval,
        expType: tabtype,
        ...this.pagination
      }
      const res = await getAbnormalRecordService(params, state => { this.tableInfo.loading = state })
      if (res) {
        const { list, total } = res.data;
        this.tableInfo.list = list;
        this.total = total;
      }
    },
    onCancel () {
      this.$emit('update:visible', false);
    },
  }
};
</script>
